<style lang="scss">
	@import "../../utils/base.scss";
</style>
<template>
	<div ref='base' class="quest_content">
		<stepInfo ref="stepInfo" v-model="stepTitleId" :ishidden="ishidden" :stepTitle="stepTitle">

			<template slot="content">
				<component v-show="stepTitleId === 0" ref="projectInfo" :is="'projectInfo'" :ifedit="ifedit" :reqId="reqId"
				 :ProleList="roleList" :Papply="applyinfo" :PprojectList="projectList"></component>
				<component v-show="stepTitleId === 1" id="resoureceInfo" ref="resoureceInfo" :is="'resoureceInfo'" :isEdit="isEdit"
				 :ifedit="ifedit" :tempResource="tempResource" :Papply="applyinfo" :Presources="resourcesInfo"></component>
				<component v-show="stepTitleId === 2" ref="toolInfo" :is="'toolInfo'" :isEdit="isEdit" :ifedit="ifedit" :Papply="applyinfo"
				 :tempTool="tempTool" :Ptool="toolInfo"></component>
				<component v-show="stepTitleId === 3" ref="dataInfo" :is="'dataInfo'" :ifedit="ifedit" :Papply="applyinfo"></component>
				<component v-show="stepTitleId === 4" ref="account" :is="'account'" :ifedit="ifedit" :Papply="applyinfo"></component>
				<component v-show="stepTitleId === 5" ref="file" :is="'file'" :ifedit="ifedit" :filesList="filesList" v-model="applyinfo.files"></component>

				<div v-if="stepTitleId === 6" ref="allInfo">
					<component :is="'projectInfo'" :ifedit="true" :reqId="reqId" :ProleList="roleList" :Papply="applyinfo"
					 :PprojectList="projectList"></component>
					<div class="qheader" :style=" {borderBottom: '0px'}">
						<p>资源信息</p>
					</div>
					<component :is="'resoureceInfo'" :ifedit="true" :Papply="applyinfo" :Presources="resourcesInfo"></component>
					<div class="qheader" :style=" {borderBottom: '0px'}">
						<p>工具信息</p>
					</div>
					<component :is="'toolInfo'" :ifedit="true" :Papply="applyinfo" :Ptool="toolInfo"></component>
					<div class="qheader" :style=" {borderBottom: '0px'}">
						                        <p>数据信息</p>
						                    </div>
					<component :is="'dataInfo'" :ifedit="true" :Papply="applyinfo"></component>
					<div class="qheader" :style=" {borderBottom: '0px'}">
						                        <p>账号信息</p>
						                    </div>
					<component :is="'account'" :ifedit="true" :Papply="applyinfo"></component>
					<div class="qheader" :style=" {borderBottom: '0px'}">
						                        <p>附件信息</p>
						                    </div>
					<component :is="'file'" :ifedit="true" :filesList="filesList" v-model="applyinfo.files"></component>
				</div>
			</template>
		</stepInfo>
		<!-- <notice v-if="!ifedit" v-show="showmd" :serviceType="serviceType">v-print="'#printInfo'"</notice> -->
	</div>
</template>
<script>
	import ajax from "../../ajax_util"
	import Axios from 'axios'
	import projectInfo from './settledin/projectInfo'
	import resoureceInfo from './settledin/resourceInfo'
	import toolInfo from './settledin/toolInfo'
	import dataInfo from './settledin/dataInfo'
	import account from './settledin/account'
	import file from './settledin/file'
	import notice from '../../base/notice'
	import PDFJs from '../../plugins/PDFJs.js'
	import printModel from './print/print_model'
	import stepInfo from './step_info.vue'
	import excel from "../../utils/excel";

	export default {
		name: "apply",
		components: {
			projectInfo,
			resoureceInfo,
			toolInfo,
			dataInfo,
			account,
			file,
			notice,
			printModel,
			stepInfo
		},
		data() {
			const validateEntryEndTime = (rule, value, callback) => {
				if (value === '') {
					callback(new Error('请选择结束时间'));
				} else {
					if (this.applyinfo.projectInfo.entryStartTime === '') {
						callback(new Error('请选择开始时间'));
					} else if (this.applyinfo.projectInfo.entryStartTime.getTime() > value.getTime()) {
						callback(new Error('结束时间不能小于开始时间'));
					} else {
						callback()
					}
				}
			};

			return {
				test2: false,
				stepPage: "projectInfo",
				stepTitleId: 0,
				serviceType: "entry",
				stepTitle: [{
						id: 0,
						name: "基本信息",
					},
					{
						id: 1,
						name: "资源申请",
					},
					{
						id: 2,
						name: "工具申请",
					},
					{
						id: 3,
						name: "数据申请",
					},
					{
						id: 4,
						name: "账号申请",
					},
					{
						id: 5,
						name: "附件",
					},
					{
						id: 6,
						name: "概览",
					}
				],

				showFileMould: false,
				httpHeader: {
					Authorization: this.$store.state.token
				},
				dataInfoEdit: 0,
				// ifedit: this.isedit,
				disabledDate: {
					disabledDate(date) {
						return date && date.valueOf() < new Date().getTime();
					}
				},
				projectInfoValidate: {
					roleId: [{
						required: true,
						type: 'number',
						message: '请选择租户角色',
						trigger: 'change'
					}, ],
					projectId: [{
						required: true,
						type: 'number',
						message: '请选择关联项目',
						trigger: 'change'
					}, ],
					entryStartTime: [{
						required: true,
						type: 'date',
						message: '请选择开始时间',
						trigger: 'change'
					}],
					entryEndTime: [{
						required: true,
						validator: validateEntryEndTime,
						trigger: 'blur'
					}],
					entryPosition: [{
						required: true,
						type: 'string',
						message: '请选择入驻位置',
						trigger: 'change'
					}],
					projectType: [{
						required: true,
						type: 'string',
						message: '请选择项目类型',
						trigger: 'change'
					}],
					projectManager: [{
						required: true,
						type: 'string',
						message: '请填写项目经理',
						trigger: 'blur'
					}],
					managerTel: [{
							required: true,
							message: '请填写项目经理联系方式',
							trigger: 'blur'
						},
						{
							type: 'string',
							pattern: /^[1]+\d{10}$/,
							message: '请输入正确的联系方式',
							trigger: 'blur'
						}
					],
					projectDoc: [{
						required: true,
						type: 'string',
						message: '请填写项目描述',
						trigger: 'blur'
					}],
				},

				fileUrl: this.CONFIG.file_url,
				// ifedit:false,   //是否可以修改编辑
				readonly: true, //是否只读
				labelWidth: 140,
				bealoonTrue: true,
				file: null,
				loadingStatus: false,
				fileUpLoadAction: "",
				name: "",
				//租户列表
				roleList: [],
				//项目名称
				projectList: [],
				//资源清单相关基础信息
				resourcesInfo: {
					severColumns: [{
							title: "*服务类型",
							align: "center",
							// width: 110,
							key: "severName",
							slot: "severName",
						},
						{
							title: "*操作系统",
							align: "center",
							width: 110,
							key: "id",
							slot: "os"
						},
						{
							title: "*raid方式",
							align: "center",
							children: [{
									title: '*系统盘',
									align: 'center',
									width: 110,
									slot: "sysRaid"
								},
								{
									title: '*数据盘',
									align: 'center',
									width: 110,
									slot: "dataRaid"
								},
							]
						},
						{
							title: "*部署区域",
							align: "center",
							width: 110,
							slot: "place"
						},
						{
							title: "*台数",
							align: "center",
							width: 90,
							slot: "quantity"
						},
						{
							title: "测算依据/必要性说明",
							align: "center",
							// width: 140,
							slot: "purpose"
						},
						{
							slot: 'action',
							align: 'center',
							width: 90,
							renderHeader: (h, index) => {
								return h('div', [
									h('Button', {
										props: {
											type: 'primary',
											// size: 'small'
										},
										on: {
											click: () => {
												if (!this.ifedit) {
													this.addRow()
												}
											}
										}
									}, '新增')
								])
							}
						},
					],

					transfer: true,
					// 资源服务title
					columns: [
						// {
						//   title: " ",
						//   align: "center",
						//   width: 60,
						//   key: "id",
						//   slot: "check",
						//   fixed: 'left'
						// },
						// {
						//     title: '服务类型',
						//     key: 'clazz',
						//     align: 'center',
						//     width: 100
						// },
						{
							title: '服务类型',
							key: 'serviceName',
							align: 'left',
							width: 150,
							fixed: 'left',
							slot: "serviceName"
						},
						{
							title: '服务名称    ',
							key: 'subName',
							align: 'left',
							minWidth: 160,
							slot: "subName"
						},
						{
							title: '*可选项',
							key: 'options',
							align: 'left',
							minWidth: 450,
							slot: 'options'
						},
						{
							title: '*测算依据',
							key: 'reason',
							align: 'left',
							minWidth: 300,
							slot: 'reason'
						},
					],
				},
				//print 打印时的表头
				resourcesInfo2: {
					severColumns: [{
							title: "*服务类型",
							align: "center",
							// width: 110,
							key: "severName",
							slot: "severName",
						},
						{
							title: "*操作系统",
							align: "center",
							width: 110,
							key: "id",
							slot: "os"
						},
						{
							title: "*raid方式",
							align: "center",
							children: [{
									title: '*系统盘',
									align: 'center',
									width: 110,
									slot: "sysRaid"
								},
								{
									title: '*数据盘',
									align: 'center',
									width: 110,
									slot: "dataRaid"
								},
							]
						},
						{
							title: "*部署区域",
							align: "center",
							width: 110,
							slot: "place"
						},
						{
							title: "*台数",
							align: "center",
							width: 90,
							slot: "quantity"
						},
						{
							title: "测算依据/必要性说明",
							align: "center",
							// width: 140,
							slot: "purpose"
						},
						{
							slot: 'action',
							align: 'center',
							width: 90,
							renderHeader: (h, index) => {
								return h('div', [
									h('Button', {
										props: {
											type: 'primary',
											// size: 'small'
										},
										on: {
											click: () => {
												if (!this.ifedit) {
													this.addRow()
												}
											}
										}
									}, '新增')
								])
							}
						},
					],

					transfer: true,
					// 资源服务title
					columns: [{
							title: '服务类型',
							key: 'serviceName',
							align: 'left',
							width: 120,
							slot: "serviceName"
						},
						{
							title: '服务名称    ',
							key: 'subName',
							align: 'left',
							width: 120,
							slot: "subName"
						},
						{
							title: '*可选项',
							key: 'options',
							align: 'left',
							width: 300,
							slot: 'options'
						},
						{
							title: '*测算依据',
							key: 'reason',
							align: 'left',
							// minWidth: 300,
							slot: 'reason'
						},
					],
				},
				//工具相关基础信息
				toolInfo: {
					toolColumns: [{
							title: '服务类型',
							key: 'clazz',
							align: 'left',
							width: 100,
							slot: "clazz"
						},
						{
							title: '服务类型',
							key: 'serviceName',
							align: 'left',
							width: 100,
							slot: "serviceName"
						},
						{
							title: '服务名称    ',
							key: 'subName',
							align: 'left',
							width: 100,
							slot: "subName"
						},
						{
							title: '*可选项',
							key: 'options',
							align: 'left',
							slot: 'options'
						},
						{
							title: '*测算依据',
							key: 'reason',
							align: 'left',
							slot: 'reason'
						}
						// {
						//     title: "单位",
						//     align: "center",
						//     minWidth: 80,
						//     key: "unit",
						// },
						// {
						//     title: "分配数量",
						//     align: "center",
						//     width: 100,
						//     key: "quantity",
						//     slot: "quantity"
						// },
						// {
						//     title: '单位',
						//     // key: 'unit',
						//     align: 'center',
						//     slot: 'unit'
						// },
					],
					toolList: [],
					needResources: [],
					needSevers: [],
					toolColumns2: [{
							title: "可选服务器资源",
							align: "center",
							key: "name",
						},
						{
							title: '*数量',
							key: 'isUse',
							align: 'center',
							slot: 'count'
						},
						{
							title: '*单位',
							key: 'unit',
							align: 'center',
							slot: 'unit'
						},
						{
							title: '测算依据',
							key: 'reason',
							align: 'center',
							slot: 'reason'
						},
					]
				},
				//数据相关基础信息
				dataInfo: {
					click: true,
					clickindex: "",
					columnsTitle: [
						"序号",
						"*字段名",
						"*字段类型",
						"*是否加密",
						"*是否必填",
						"备注"
					],
				},
				accountInfo: {
					columns: [{
							title: "序号",
							align: "center",
							width: 80,
							key: "count",
							slot: "count",
						},
						{
							title: "*租户成员姓名",
							align: "center",
							width: 120,
							slot: "name"
						},
						{
							title: "*一级4A账号",
							align: "center",
							// width: 110,
							key: "fourA",
							slot: "fourA",
						},
						{
							title: "*成员归属",
							align: "center",
							// width: 110,
							key: "userCompany",
							slot: "userCompany",
						},
						{
							title: "*账号角色",
							align: "center",
							// width: 110,
							key: "userRole",
							slot: "userRole",
						},
						{
							title: "备注",
							align: "center",
							// width: 110,
							key: "des",
							slot: "des",
						},
						{
							slot: 'action',
							align: 'center',
							width: 90,
							renderHeader: (h, index) => {
								return h('div', [
									h('Button', {
										props: {
											type: 'error',
											size: 'small'
										},
										on: {
											click: () => {
												if (!this.ifedit) {
													this.addAccountRow()
												}
											}
										}
									}, '新增')
								])
							}
						},
					]
				},
				accountIndex: [],
				applyinfo: {
					reqSubject: "",
					base: {
						applyDate: "",
						compId: "",
						userName: "",
						userId: "",
						applyCardId: "",
						telephone: "",
						email: "",
						applydept: ""
					},
					projectInfo: {
						roleId: "", //租户id
						roleName: "", //租户名称
						projectId: "", //关联项目ID
						projectName: "", //关联项目名称

						entryStartTime: "", //开始时间
						entryEndTime: "", //结束时间
						entryCycle: "", //入驻周期
						entryPosition: "", //入驻地址
						isContract: "", //是否签订合同
						projectType: "", //项目类型

						projectManager: "", //项目经理
						business: "",
						managerTel: "", //项目经理联系方式
						projectDoc: "" //项目介绍
					},
					remark: {
						alloType: "",
						entrySysId: "",
					},
					resourcesInfo: {
						len: 0, //合并的行数
						resourceChcekList: [], //选择的申请资源清单列表
						resourceInfo: [], //资源清单字段详情
						seversList: [], //云服务字段列表
					},
					resources: [],
					severs: [],
					tools: {
						checkList: [], //选择的列表
						checkResourceList: [], //选择的工具资源
						needResources: [],
						needSevers: []
					},
					datas: [],
					account: {
						peopleList: [],
						people: [
							// {
							//   peopleUserId: 0,
							//   peopleName: "",
							//   tenantName: "",
							//   fourA: "",
							//   igroup: "",
							//   outterCompany: "",
							//   isEtl: false,
							//   isPaas: false,
							//   isUap: false,
							//   isHadoop: false,
							//   isElse: false,
							//   hftps: [],
							//   paas: [],
							//   hadoops: [],
							//   elseAuthes: []
							// }
						]
					},
					files: []
				},
				tempResource: [],
				tempTool: [],
				printInfo: {
					applyinfo: {},

				},

				printBaseInfo: [],
				baseInfoLength: 0,
				printProject: [],
				projectInfoLength: 0,
				baseId: this.reqId + "base",
				projectInfoId: this.reqId + "project",
				temp_roleId: 0,
			}
		},
		created: function() {
			this.getResourceList(); //获取表单基础信息
		},
		mounted: function() {},

		methods: {
			// 导出资源数据
			exportResource() {
				var option = {
					title: ['', '工具名称', '资源类型', '服务名称', '细分项名', '可选项', '描述'],
					body: [],
					name: '入驻服务申请资源信息表_' + this.reqId,
					suffix: 'xlsx',
					merges: []
				}
				console.log("this.================>", this.applyinfo.resourcesInfo.resourceInfo, this.toolInfo.toolList)
				var resourceList = this.applyinfo.resourcesInfo.resourceInfo
				var toolList = this.toolInfo.toolList
				if (this.isEdit == 1) {
					resourceList = this.tempResource
					toolList = this.tempTool
				}
				var row = 1
				var mergeRow = 1
				if (resourceList.length > 0) {
					option.body.push(['资源', '资源类型', '资源类型', '服务名称', '细分项名', '可选项', '描述'])
					option.merges.push({
						s: {
							r: 0,
							c: 1
						},
						e: {
							r: 0,
							c: 2
						}
					})
					resourceList.forEach(item => {
						var resource = this.sort(item.list, option, '')
						mergeRow += resource.length - 1

						option.merges.push({
							s: {
								r: row,
								c: 1
							},
							e: {
								r: mergeRow,
								c: 2
							}
						})
						mergeRow += 1
						row = mergeRow
					})
					option.merges.push({
						s: {
							r: 0,
							c: 0
						},
						e: {
							r: mergeRow - 1,
							c: 0
						}
					})
				}
				if (toolList.length > 0) {
					if (option.body.length > 0) {
						mergeRow += 1
						row = mergeRow
					}
					option.body.push(['工具', '工具名称', '资源类型', '服务名称', '细分项名', '可选项', '描述'])
					const toolRow = row - 1
					toolList.forEach(item => {
						var resource = []
						if (item.needResources != undefined && item.needResources != null && item.needResources.length > 0) {
							resource = this.sort(item.needResources, option, item.toolName)
						} else {
							option.body.push(["", item.toolName, '无', '无', '无', '无', '无'])
							resource = [1]
						}

						mergeRow += resource.length - 1

						option.merges.push({
							s: {
								r: row,
								c: 1
							},
							e: {
								r: mergeRow,
								c: 1
							}
						})

						mergeRow += 1
						row = mergeRow
					})

					option.merges.push({
						s: {
							r: toolRow,
							c: 0
						},
						e: {
							r: mergeRow - 1,
							c: 0
						}
					})
				}

				if (this.applyinfo.datas.length > 0) {
					var number = 0
					this.applyinfo.datas.forEach(item => {
						number += item.fields.length
					})
					option.body.push(['数据', '数据表总数(张)', "", '', '', '', this.applyinfo.datas.length])
					option.body.push(['数据', '数据字段总数(个)', "", '', '', '', number])

					row = mergeRow
					option.merges.push({
						s: {
							r: row,
							c: 0
						},
						e: {
							r: mergeRow + 1,
							c: 0
						}
					}, {
						s: {
							r: row,
							c: 1
						},
						e: {
							r: row,
							c: 5
						}
					}, {
						s: {
							r: row + 1,
							c: 1
						},
						e: {
							r: row + 1,
							c: 5
						}
					})
				}


				console.log("-option--->", option)

				console.log("-this.tempTool--->", this.tempTool)
				if (option.body.length > 0) {
					excel.exportFromArray(option)
				} else {
					this.$Message.error("暂无资源可导出!")
				}
			},
			sort(data, option, toolName) {
				var t = JSON.stringify(data)
				var temp = JSON.parse(t)
				var temp2 = []
				temp2 = temp.sort((a, b) => {
					return a['clazz'].localeCompare(b['clazz']) //用本地特定的顺序来比较两个字符串。
				})
				var resource = []
				temp2.forEach(item => {
					item.clazz = item.clazz.split(".").length > 1 ? item.clazz.split(".")[1] : item.clazz
					item.serviceName = item.serviceName.split(".").length > 1 ? item.serviceName.split(".")[1] : item.serviceName
					item.subName = item.subName.split(".").length > 1 ? item.subName.split(".")[1] : item.subName
					var otherInfo = ""
					if (item.resourcetype == 0) {
						otherInfo = "数量：" + item.val + "  单位：" + item.quotaUnit
					} else if (item.resourcetype == 1) {
						otherInfo = item.val
					} else if (item.resourcetype == 3) {
						otherInfo = item.options[0] + ': ' + item.val
					} else if (item.resourcetype == 4) {
						otherInfo = item.val
					} else if (item.resourcetype == 5) {
						otherInfo = "双副本数量：" + item.val + "  单位：" + item.quotaUnit + "  单副本数量：" + item.val / 2
					} else if (item.resourcetype == 6) {
						otherInfo = "三副本数量：" + item.val + "  单位：" + item.quotaUnit + "  单副本数量：" + parseFloat(item.val / 3).toFixed(2)
					}
					var temp = []
					temp.push("")
					if (toolName == "") {
						temp.push(item.clazz)
					} else {
						temp.push(toolName)
					}
					temp.push(item.clazz)
					temp.push(item.serviceName)
					temp.push(item.subName)
					temp.push(otherInfo)
					temp.push(item.purpose)
					option.body.push(temp)
					resource.push(temp)
				})
				console.log("resource------>", resource)
				return resource
			},
			exportData() {
				console.log("----导出数据目录----", this.applyinfo.datas);
				if (this.applyinfo.datas != undefined && this.applyinfo.datas != null) {
					if (this.applyinfo.datas.length > 0) {
						var option = [];
						this.applyinfo.datas.forEach(item => {
							if (item.serviceId != undefined && item.serviceId != null && item.serviceId > 0) {
								option.push(this.exportExistData(item));
							} else {
								option.push(this.exportCustomData(item));
							}
						})
						// 处理sheet名
						var tempSheetName = []
						for (let i = 0; i < option.length; i++) {
							if (tempSheetName.find(e => e == option[i].sheetName) != undefined) {
								option[i].sheetName += i
							} else {
								tempSheetName.push(option[i].sheetName)
							}
						}

						console.log("3333333333", option);
						excel.exportSheetFromArray(option)
					} else {
						this.$Message.error("暂无数据目录信息可导出!")
					}
				} else {
					this.$Message.error("暂无数据目录信息可导出!")
				}
			},
			exportExistData(data) {
				var option = {
					title: [],
					body: [],
					name: '入驻服务申请数据目录信息表_' + this.reqId,
					suffix: 'xlsx',
					sheetName: '',
					merges: [{
							s: {
								r: 0,
								c: 0
							},
							e: {
								r: 0,
								c: 13
							}
						},
						{
							s: {
								r: 4,
								c: 0
							},
							e: {
								r: 4,
								c: 13
							}
						}
					]
				}
				var table = data.service;
				var fields = data.fields;
				var temp = table["tableName"].length > 20 ? table["tableName"].substring(0, 20) + '...' : table["tableName"]
				var badchars = "][*?\/\\".split("");
				badchars.forEach(function(c) {
					if (temp.indexOf(c) != -1)
						temp = temp.replace(c, '');
				});
				option.sheetName = temp;

				var body = [];
				body.push(1);
				body.push(table["tableName"]);
				body.push(table["tableNameEn"]);
				body.push(table["dataLevel"]);
				body.push(table["domain"]);
				body.push(table["subjectField"]);
				body.push(table["dataOpenLevel"]);
				body.push(table["cycleType"]);
				body.push(table["keepTime"]);
				body.push(table["keepUnit"]);
				body.push(table["dataScope"]);
				body.push(table["oriSys"]);
				body.push(table["caliber"]);
				body.push(data.purpose);
				body.push(data["fields"].length + '/' + data['len']);

				var tableTitle = [];
				tableTitle.push("（" + table["tableName"] + "）" + "数据表信息");
				option.body.push(tableTitle);
				option.body.push(['序号', '表中文名', '表英文名', '层级', '所属域', '主题域', '数据开放推荐级别', '更新周期', '保存时长', '保存时长单位', '数据范围', '所属系统',
					'业务口径', '用途','字段数占比'
				]);
				option.body.push(body);

				option.body.push(["", "", "", "", "", "", "", "", "", "", "", ""]);

				option.body.push(["选择字段信息"]);
				option.body.push(["序号", "字段属性", "字段名称", "数据类型", "数据样例", "是否加密", "是否必选", "字段必要性说明"]);
				for (var i = 0; i < fields.length; i++) {
					var arr = [];
					arr.push(i + 1);
					arr.push(fields[i].fieldNameEn);
					arr.push(fields[i].fieldName);
					arr.push(fields[i].fieldType);
					arr.push(fields[i].fieldEnum);
					if (fields[i].isEncryption == 1) {
						arr.push("是");
					} else {
						arr.push("否");
					}
					if (fields[i].isRequired == 1) {
						arr.push("是");
					} else {
						arr.push("否");
					}
					arr.push(fields[i].remark);

					option.body.push(arr);
				}

				return option;
			},
			exportCustomData(data) {
				console.log('exportCustomData',data)
				var option = {
					title: [],
					body: [],
					name: '入驻服务申请数据目录信息表_' + this.reqId,
					suffix: 'xlsx',
					sheetName: '',
					merges: [{
							s: {
								r: 0,
								c: 0
							},
							e: {
								r: 0,
								c: 3
							}
						},
						{
							s: {
								r: 4,
								c: 0
							},
							e: {
								r: 4,
								c: 5
							}
						}
					]
				}

				var table = data;
				var fields = data.fields;
				var temp = table["tableName"] + "（自定义数据表）"
				var temp2 = temp.length > 20 ? temp.substring(0, 20) + '...' : temp;
				var badchars = "][*?\/\\".split("");
				badchars.forEach(function(c) {
					if (temp2.indexOf(c) != -1)
						temp2 = temp2.replace(c, '');
				});
				option.sheetName = temp2

				var body = [];
				body.push(1);
				body.push(table["tableName"]);
				body.push(table["purpose"]);
				body.push(table["cycleType"]);
				body.push(table["domain"]);

				var tableTitle = [];
				tableTitle.push("（" + table["tableName"] + "）" + "自定义数据表信息");
				option.body.push(tableTitle);
				option.body.push(['序号', '表名', '用途', '表类型', '所属域']);
				option.body.push(body);

				option.body.push(["", "", "", ""]);

				option.body.push(["自定义字段信息"]);
				option.body.push(["序号", "字段名称", "字段类型", "是否加密", "是否必选", "字段必要性说明"]);
				for (var i = 0; i < fields.length; i++) {
					var arr = [];
					arr.push(i + 1);
					arr.push(fields[i].fieldName);
					arr.push(fields[i].fieldType);
					if (fields[i].isEncryption == 1) {
						arr.push("是");
					} else {
						arr.push("否");
					}
					if (fields[i].isRequired == 1) {
						arr.push("是");
					} else {
						arr.push("否");
					}
					arr.push(fields[i].remark);

					option.body.push(arr);
				}

				return option;
			},
			exportAccount() {
				console.log("----导出账号信息----", this.applyinfo.account.people);
				if (this.applyinfo.account != undefined && this.applyinfo.account != null) {
					if (this.applyinfo.account.people != undefined && this.applyinfo.account.people != null) {
						var people = this.applyinfo.account.people;
						if (people.length > 0) {
							var option = {
								title: [],
								body: [],
								name: '入驻服务申请账号信息表_' + this.reqId,
								suffix: 'xlsx',
								sheetName: '',
								merges: []
							}

							var title = ["姓名", "已有的一级4A主账号", "成员归属", "采集交换区账号", "PaaS从账号", "UAP客户端", "Hadoop客户端", "其他(填写具体账号类型)"]
							option.body.push(title);

							people.forEach(item => {
								var account = [];
								account.push(item.peopleName);
								account.push(item.fourA);
								account.push(item.outterCompany);
								if (item.isEtl) {
									account.push("是");
								} else {
									account.push("");
								}

								if (item.isPaas) {
									account.push("是");
								} else {
									account.push("");
								}

								if (item.isUap) {
									account.push("是");
								} else {
									account.push("");
								}

								if (item.isHadoop) {
									account.push("是");
								} else {
									account.push("");
								}

								if (item.isElse) {
									account.push(item.elseAuthes[0].des);
								} else {
									account.push("");
								}

								option.body.push(account);
							})

							excel.exportFromArray(option)
						} else {
							this.$Message.error("暂无账号信息可导出!")
						}
					} else {
						this.$Message.error("暂无账号信息可导出!")
					}
				} else {
					this.$Message.error("暂无账号信息可导出!")
				}
			},
			// 打印
			print() {
				var temp = []
				temp.push({
					title: "提单人信息",
					type: "dafault",
					info: {
						printObject: this.printBaseInfo,
						printLength: this.baseInfoLength
					}
				})
				temp.push({
					title: "入驻项目信息",
					type: "dafault",
					info: {
						printObject: this.printProject,
						printLength: this.projectInfoLength
					}
				})
				temp.push({
					title: "资源信息",
					type: "entry_resoureceInfo",
					info: {
						resourcesInfo2: this.resourcesInfo2,
						applyinfo: this.printInfo.applyinfo
					}
				})
				temp.push({
					title: "工具信息",
					type: "entry_toolInfo",
					info: {
						toolInfo: this.toolInfo,
						applyinfo: this.printInfo.applyinfo
					}
				})
				temp.push({
					title: "数据信息",
					type: "entry_dataInfo",
					info: {
						applyinfo: this.printInfo.applyinfo
					}
				})
				temp.push({
					title: "账号信息",
					type: "entry_account",
					info: {
						applyinfo: this.printInfo.applyinfo
					}
				})
				// this.printInfo.toolInfo = this.toolInfo
				// this.printInfo.printBaseInfo = this.printBaseInfo
				// this.printInfo.baseInfoLength = this.baseInfoLength
				// this.printInfo.printProject = this.printProject
				// this.printInfo.projectInfoLength = this.projectInfoLength
				// this.printInfo.resourcesInfo2 = this.resourcesInfo2

				const {
					href
				} = this.$router.resolve({
					path: '/other_page/print',
					query: {
						serviceType: this.serviceType,
						printName: "入驻申请表单",
            printId: this.reqId
					}
				})
				sessionStorage[this.reqId] = JSON.stringify(temp)
				window.open(href, '_blank')
				this.newValue = false
				console.log("----rrrrr---------",window.sessionStorage.getItem('printInfo'));
			},
			cancel() {
				this.newValue = false
			},
			setApplInfo(stepId) {
				var isSubmit = true
				if (stepId == 0) {
					this.applyinfo.projectInfo = this.$refs.projectInfo.applyinfo.projectInfo
					this.projectList = this.$refs.projectInfo.projectList
					// isSubmit = this.$refs.projectInfo.validate()
					console.log("isSubmit1------->", isSubmit)
				} else if (stepId == 1) {
					this.applyinfo.resourcesInfo = this.$refs.resoureceInfo.applyinfo.resourcesInfo
					this.applyinfo.resources = this.$refs.resoureceInfo.applyinfo.resources
					// isSubmit = !this.$refs.resoureceInfo.validate()
					console.log("isSubmit2------->", isSubmit)
				} else if (stepId == 2) {
					this.applyinfo.tools = this.$refs.toolInfo.applyinfo.tools
					isSubmit = true
				} else if (stepId == 3) {
					this.applyinfo.datas = this.$refs.dataInfo.applyinfo.datas
					// isSubmit = !this.$refs.dataInfo.validate()
					console.log("isSubmit3------->", isSubmit)
				} else if (stepId == 4) {
					this.applyinfo.account = this.$refs.account.applyinfo.account
					// isSubmit = !this.$refs.account.validate()
				} else if (stepId == 5) {
					isSubmit = true
				} else {
					isSubmit = true
				}

				return isSubmit
			},
			clicks(index) {
				if (this.clickindex === index) {
					if (this.click) {
						this.click = false
					} else {
						this.click = true
					}
				} else {
					if (!this.click) {
						this.click = true
					}
				}
				this.clickindex = index;
			},
			// 选择工具
			chackeTool(id) {
				if (this.applyinfo.tools.checkList.indexOf(id) == -1) {
					this.applyinfo.tools.checkList.push(id)
				} else(
					this.applyinfo.tools.checkList.splice(this.applyinfo.tools.checkList.indexOf(id), 1)
				)
			},
			//获取租户角色
			getRoleLis(userId) {
				var url = this.CONFIG.url_know + "/getManager/" + userId
				var that = this;
				ajax.get({
					url: url,
					that: that,
					params: null,
					success: function(data) {
						console.log("======data======", data, that.applyinfo.base)
						that.roleList = data

						if (that.temp_roleId > 0) {
							that.checkRole(that.temp_roleId);
						}
					}
				})
			},
			//获取草稿详情
			getDrafts() {
				var url = this.CONFIG.base_url_test + "/draft/content/" + this.draftsId
				var that = this;
				ajax.get({
					url: url,
					that: that,
					params: null,
					success: function(data) {
						console.log("------data------", data);
						that.temp_roleId = data.req.base.roleId
						that.applyinfo.remark = data.req.object.remark
						that.applyinfo.base = data.req.object.base
						that.getRoleLis(data.req.object.base.userId)
						//that.checkRole(data.req.object.projectInfo.roleId)
						that.applyinfo.files = data.req.files
						that.applyinfo.projectInfo = data.req.object.projectInfo
						that.handleInfo(data.req.object)
						that.applyinfo.reqSubject = data.req.puslicInfo.reqSubject
					}
				})
			},
			checkRole(roleId) {
				console.log("-----this.projectList--------", this.roleList);
				if (roleId != undefined && roleId != null && roleId != "") {
					// var url = this.CONFIG.url_know + "/getProjects/" + roleId
					// var that = this;
					// ajax.get({
					// 	url: url,
					// 	that: that,
					// 	params: null,
					// 	success: function(data) {
					// 		that.projectList = data
					// 	}
					// })
					this.roleList.some(item => {
						if (roleId == item.id) {
							this.projectList = item.projects
							console.log("-----this.projectList--------", this.projectList);
							return true
						}
					})
				}
			},

			//获取草稿或者表单详情
			setInfo() {
				if (this.reqId != null) {
					this.getApplyInfo(); //获取表单详情
				} else if (this.draftsId != null) {
					console.log("获取草稿---------->")
					this.getDrafts()
				} else {
					this.getUserInfo(); // 获取登录用户信息
				}
			},
			// 获取提交表单人基本信息
			getApplyUser(userId) {
				var that = this;
				var url = this.CONFIG.url_know + '/user/' + userId;
				ajax.get({
					url: url,
					that: that,
					success: function(data) {
						console.log("user----->", data)
						that.applyinfo.base.userName = data.user_name
						that.applyinfo.base.userId = data.id
						that.applyinfo.base.applyCardId = data.id_card
						that.applyinfo.base.telephone = data.phone
						that.applyinfo.base.email = data.email
						that.applyinfo.base.applydept = that.processInfo.dptName
					}
				})
			},
			getApplyInfo() {

				var data = this.processInfo
				this.dataInfoEdit = this.isEdit
				if (this.processInfo.content.remark != undefined) {
					this.applyinfo.remark = this.processInfo.content.remark
				}
				console.log("----data111--------", data);
				// this.getApplyUser(data.base.userId)
				this.setUserInfo(data.base.userFBean)
				this.applyinfo.base.applydept = this.processInfo.dptName
				this.applyinfo.reqSubject = this.processInfo.reqSubject
				this.setProjectInfo(data.base.project)
				this.applyinfo.account = this.setAccount(data.content.account);
				if (this.isEdit == 1) {
					this.temp_roleId = this.processInfo.base.role.id
					this.getRoleLis(data.base.userFBean.id);
					this.checkRole(this.processInfo.base.role.id)
					this.handleInfo(data.content)
				} else {
					this.handleApplyInfo(data)
				}
				if (data.files != undefined && data.files != null) {
					this.applyinfo.files = data.files
				}
				this.printInfo.applyinfo = JSON.parse(JSON.stringify(this.applyinfo))
				this.stepTitleId = 6
			},
			setUserInfo(userInfo) {
				this.applyinfo.base.userName = userInfo.user_name
				this.applyinfo.base.userId = userInfo.id
				this.applyinfo.base.applyCardId = userInfo.id_card
				this.applyinfo.base.telephone = userInfo.phone
				this.applyinfo.base.email = userInfo.email
			},
			setAccount(account) {
				if (account != null && account.people != undefined && account.people != null) {
					account.peopleList = [];
					for (var i = 0; i < account.people.length; i++) {
						if (account.people[i].hftps.length > 0) {
							for (var j = 0; j < account.people[i].hftps.length; j++) {
								if (account.people[i].hftps[j].isCluster) {
									account.people[i].isEtl = true;
								}

								if (account.people[i].hftps[j].isClient) {
									account.people[i].isUap = true;
								}
							}
						}

						if (account.people[i].paas.length > 0) {
							account.people[i].isPaas = true;
						}

						if (account.people[i].hadoops.length > 0) {
							account.people[i].isHadoop = true;
						}

						if (account.people[i].elseAuthes.length > 0) {
							account.people[i].isElse = true;
						}

						var j = {
							id: "",
							user_name: "",
							fourA: "",
							structs: []
						}
						var item = account.people[i]
						if (item.peopleUserId != undefined && item.peopleUserId != null &&
							typeof item.peopleUserId == 'number' && item.peopleUserId != 0) {
							j.id = account.people[i].peopleUserId;
						} else {
							account.people[i].peopleUserId = account.people[i].peopleName;
							j.id = account.people[i].peopleName;
						}
						j.fourA = item.fourA
						j.user_name = account.people[i].peopleName;
						account.peopleList.push(j);

						if (account.people[i].isExpand == undefined) {
							account.people[i].isExpand = -1;
						}
					}
				} else {
					account = {
						people: [],
						peopleList: []
					}
				}
				return account;
			},
			//转换info格式
			handleInfo(content) {
				var info = this.applyinfo
				var data = content
				console.log("handle ---->", content)
				if (data.datas == undefined || data.datas == null) {
					info.datas = []
				} else {
					info.datas = data.datas
				}
				this.tempTool = []
				data.tools.forEach(tool => {
					info.tools.checkList.push(tool.toolId)
					var t = this.toolInfo.toolList.find(e => tool.toolId == e.toolId)
					if (t == undefined) {
						this.toolInfo.toolList.push(tool)
					}
					this.toolInfo.toolList.forEach((item, index) => {
						if (tool.toolId == item.toolId) {
							if (tool.needResources != null) {
								tool.needResources.forEach((k, i) => {
									console.log("kkkk>---------->", k)
									var t = k.val
									if (k.quotaValue != undefined && k.quotaValue != null) {
										var quotaValue = JSON.parse(JSON.stringify(k.quotaValue))
										var quotaUnit = JSON.parse(JSON.stringify(k.quotaUnit))
									}
									if (k.resourcetype == 4 && typeof t === 'string') {
										tool.needResources[i].quotaValue = JSON.parse(t)
										tool.needResources[i].val = JSON.parse(t)
									} else if (k.resourcetype == 0 || k.resourcetype == 5 || k.resourcetype == 6) {
										tool.needResources[i].quotaValue = parseFloat(t)
										tool.needResources[i].val = parseFloat(t)
									} else {
										tool.needResources[i].quotaValue = t
										tool.needResources[i].val = t
									}
									tool.needResources[i].quotaUnit = k.unit
									tool.needResources[i].check = true

									if (tool.default != undefined && tool.default == 1) {
										tool.needResources[i].quotaValue = quotaValue
										tool.needResources[i].quotaUnit = quotaUnit

										this.toolInfo.toolList[index].default = tool.default
									}
									this.toolInfo.toolList[index].needResources[i] = tool.needResources[i]
								})
							}
							this.tempTool.push(this.toolInfo.toolList[index])
						}
					})
				});
				console.log("--item--------->", this.toolInfo.toolList)

				let set = new Set

				var resT = []
				data.resources.forEach(res => {
					this.applyinfo.resourcesInfo.resourceInfo.some((key, index) => {
						if (res.clazz === key.resourceName) {
							set.add(res.clazz)
							if (key.list.find(e => e.id == res.serviceId) == undefined) {
								key.list.push(res)
							}
							key.list.some((item, index2) => {
								if (res.clazz === item.clazz && res.serviceName === item.serviceName && res.subName ===
									item.subName) {
									this.applyinfo.resourcesInfo.resourceInfo[index].list[index2] = res
									var t = res.val
									var k = this.applyinfo.resourcesInfo.resourceInfo[index].list[index2]
									if (k.resourcetype == 4 && typeof t === 'string') {
										k.quotaValue = JSON.parse(t)
										k.val = JSON.parse(t)
									} else if (k.resourcetype == 0 || k.resourcetype == 5 || k.resourcetype == 6) {
										k.quotaValue = parseFloat(t)
										k.val = parseFloat(t)
									} else {
										k.quotaValue = t
										k.val = t
									}
									k.quotaUnit = res.unit
									k.check = true
									console.log(this.applyinfo.resourcesInfo.resourceInfo[index].list[index2])
									resT.push(this.applyinfo.resourcesInfo.resourceInfo[index].list[index2])
									return
								}
							})
							return
						}
					})
				});

				this.tempResource = []
				var _self = this.tempResource
				resT.forEach(item => {
					console.log("item----->", item.val)
					var clazz = item.clazz
					if (_self.length === 0) {
						_self.push({
							'resourceName': clazz,
							'list': [item],
							rowspan: 1
						})
					} else {
						var service = _self.find(e => e.resourceName == clazz)
						if (service != undefined) {
							service.list.push(item)
						} else {
							_self.push({
								'resourceName': clazz,
								'list': [item],
								rowspan: 1
							})
						}
					}
				})
				console.log("_self ---->", _self)
				info.account = this.setAccount(data.account);

				console.log("info ---->", info.account)

				set.forEach(item => {
					info.resourcesInfo.resourceChcekList.push(item)
				})

			},
			//处理表单详情
			handleApplyInfo(data) {
				console.log("this.processInfo---->", data)
				var info = this.applyinfo
				var content = data.content
				var projectModel = data.projectModel
				if (content.datas == undefined || content.datas == null) {
					info.datas = []
				} else {
					info.datas = content.datas

				}
				content.tools.forEach((tool, index) => {
					if (tool.id === undefined) {
						tool.id = tool.toolId
					}
					info.tools.checkList.push(tool.toolId)
					tool.chack = []
					if (tool.needResources != null) {
						tool.needResources.forEach((item, k) => {
							console.log("item------------->", item)
							if (item.quotaValue == undefined) {
								if (item.resourcetype == 4 && item.val != null && typeof item.val === 'string') {
									var t = item.val
									content.tools[index].needResources[k].quotaValue = JSON.parse(t)
									content.tools[index].needResources[k].val = JSON.parse(t)
								} else {
									content.tools[index].needResources[k].quotaValue = item.val
								}
								content.tools[index].needResources[k].quotaUnit = item.unit
							}
							tool.chack.push(item.id)
						})
					}
				});
				this.toolInfo.toolList = content.tools
				this.applyinfo.resourcesInfo.len = 0

				this.applyinfo.resourcesInfo.resourceInfo = []
				this.handleSpan(content.resources)
				this.applyinfo.resourcesInfo.resourceInfo.forEach(item => {
					info.resourcesInfo.resourceChcekList.push(item.resourceName)
				})

			},
			//设置项目基础详情
			setProjectInfo(data) {
				console.log("data------------->", data)
				var info = this.applyinfo.projectInfo
				info.roleId = this.processInfo.base.role.id
				info.roleName = this.processInfo.base.role.tenant_name
				info.projectId = data.id
				info.projectName = data.project
				info.entryStartTime = data.create_time != null && data.create_time != '' ? this.formatTime(data.create_time) :
					''
				info.entryEndTime = data.end_time != null && data.end_time != '' ? this.formatTime(data.end_time) : ''
				info.entryCycle = data.cycle
				info.entryPosition = data.position
				info.isContract = data.isContract
				info.projectType = data.projectType
				info.projectManager = data.manager
				if (data.business == undefined || data.business == null || data.business == "") {
					info.business = data.tenant_business
				} else {
					info.business = data.business
				}
				info.managerTel = data.manager_phone
				info.projectDoc = data.des
			},
			//资源清单_获取基础信息
			getResourceList() {
				console.log("获取基础信息---->")
				var url = this.CONFIG.progress_url + "/service-list"
				var that = this;
				ajax.get({
					url: url,
					that: that,
					params: null,
					success: function(data) {
						var resourceList = data.resourceList
						that.handleSpan(resourceList)
						that.applyinfo.resourcesInfo.seversList = data.severList
						data.toolList.forEach((item, index) => {
              that.$delete(data.toolList[index], "spServiceType")
							data.toolList[index].toolId = item.id
							data.toolList[index].default = 0
							data.toolList[index].chack = []
							if (data.toolList[index].needResources != null) {
								data.toolList[index].needResources.forEach((i, k) => {
									var t = i.quotaValue
									if (i.resourcetype == 4 && (typeof i.quotaValue == 'string')) {
										i.quotaValue = JSON.parse(t)
										i.val = JSON.parse(t)
									} else if (i.resourcetype == 0 || i.resourcetype == 5 || i.resourcetype == 6) {
										i.quotaValue = parseFloat(t)
										i.val = parseFloat(t)
									} else {
										i.val = t
									}
									data.toolList[index].needResources[k].check = true
									data.toolList[index].needResources[k].toolId = item.id
									data.toolList[index].needResources[k].unit = data.toolList[index].needResources[k].quotaUnit
									data.toolList[index].needResources[k].quantity = data.toolList[index].needResources[k].quota
									data.toolList[index].needResources[k].serviceId = i.id
									data.toolList[index].needResources[k].purpose = "默认"
								})
							}
						})
						that.toolInfo.toolList = data.toolList
						// that.toolInfo.needResources = data.toolList.needResources
						// that.toolInfo.needSevers = data.toolList.needSevers
						that.toolInfo.needResources = data.resourceList
						that.toolInfo.needSevers = data.severList
						that.setInfo()
					}
				})
			},
			getUserInfo() {
				console.log("获取用户基础信息------->", this.$store.state.user)
				var temp = this.$store.state.user
				this.applyinfo.base.userName = temp.user_name
				this.applyinfo.base.userId = temp.id
				this.applyinfo.base.applyCardId = temp.id_card
				this.applyinfo.base.telephone = temp.phone
				this.applyinfo.base.email = temp.email
				this.applyinfo.base.applydept = temp.department
				this.getRoleLis(temp.id); //获取角色列表
			},
			//合并整理资源清单
			handleSpan(temp) {
				var _self = this.applyinfo.resourcesInfo.resourceInfo

				temp.forEach(item => {
					console.log("item----->", item.val)
					if (item.quantity === undefined) {
						item.quantity = 0
					}
					if (item.val == undefined || item.val == null || item.val == '') {
						if (item.resourcetype == 4) {
							item.val = []
						} else {
							item.val = null
						}
					} else {
						if (item.resourcetype == 4 && typeof item.val == 'string') {
              console.log("item.val = ", item.val)
							item.quotaValue = JSON.parse(item.val)
							item.val = JSON.parse(item.val)
						} else {
							item.quotaValue = item.val
						}
						item.quotaUnit = item.unit
					}
					var clazz = item.clazz
					if (_self.length === 0) {
						_self.push({
							'resourceName': clazz,
							'list': [item],
							rowspan: 1
						})
					} else {
						var service = _self.find(e => e.resourceName == clazz)
						if (service != undefined) {
							service.list.push(item)
							if (service.list[service.list.length - 1].serviceName == service.list[service.list.length - 2].serviceName &&
								service.list[service.list.length - 1].serviceName == service.list[0].serviceName) {
								service.rowspan++
							}
						} else {
							_self.push({
								'resourceName': clazz,
								'list': [item],
								rowspan: 1
							})
						}
					}
				})

			},

			chenckList() {
				if (this.getInfo() == "") {
					this.$Message.error("请至少填写一种资源申请!")
					return false
				} else {
					return true
				}
			},
			//获取表单信息并加以处理
			getInfo() {
				var temp = this.applyinfo
				var info = {
					base: {},
					projectInfo: {},
					resources: [],
					severs: [],
					tools: [],
					datas: [],
					files: [],
					account: {},
					remark: {},
				}

				info.base = temp.base
				info.base.dptName = this.applyinfo.base.applydept
				info.projectInfo = temp.projectInfo
				info.remark = temp.remark
				info.datas = temp.datas
				info.files = temp.files

				var accountList = {
					people: []
				}
				if (temp.account.people.length > 0) {
					temp.account.people.forEach(item => {
						if (item.peopleName != '') {
							if (typeof item.peopleUserId != 'number') {
								item.peopleUserId = 0
							}
						}
						accountList.people.push(item)
					})
				}
				info.account = accountList

				//处理resourceList
				var chack = temp.resourcesInfo.resourceChcekList
				var resourceList = temp.resourcesInfo.resourceInfo
				chack.forEach(key => {
					if (key === "severs") {
						info.severs = temp.severs
					} else {
						resourceList.some(item => {
							if (key === item.resourceName) {
								item.list.forEach(list => {
									if (list.check) {
										var t1 = JSON.stringify(list)
										var t2 = JSON.parse(t1)
										if (t2.resourcetype == 4) {
											t2.val = JSON.stringify(list.val)
											console.log("------------>转换", t2.val)
										}
										if (t2.serviceId == undefined || t2.serviceId == null) {
											t2.serviceId = list.id
										}
										info.resources.push(t2)
									}
								})
								return true
							}
						})

					}
				});
				//处理工具
				info.tools = this.getTool()
				var publicInfo = this.utils.setPublicInfoInfo(this.applyinfo.reqSubject, 0, 0, temp.projectInfo.projectDoc)
				var submits = {
					base: {
						roleId: temp.projectInfo.roleId,
						projectId: temp.projectInfo.projectId
					},
					object: info,
					files: info.files,
					puslicInfo: publicInfo
				}
				return submits;
			},
			// 处理工具信息
			getTool() {
				var toolCheck = this.applyinfo.tools.checkList
				var temp = []
				toolCheck.forEach(item => {
					this.toolInfo.toolList.some(tool => {
						if (item === tool.toolId) {
							var t1 = JSON.stringify(tool)
							var t2 = JSON.parse(t1)
							if (t2.needResources != null) {
								t2.needResources.forEach(i => {
									if (t2.default == 0) {
										i.val = i.quotaValue
										i.unit = i.quotaUnit
									}
									if (i.resourcetype == 4) {
										i.val = JSON.stringify(i.val)
										i.quotaValue = JSON.stringify(i.quotaValue)
									}
								})
							}
							temp.push(t2)
							return true
						}
					})
				})
				return temp
			},
			validate() {
				var isSubimt = false

				var isStep6 = false;

				console.log("-------validate-------")
				if (!this.$refs.projectInfo.validate()) {
					this.stepTitleId = 0
				} else if (this.$refs.resoureceInfo.validate()) {
					this.stepTitleId = 1
				} else if (this.$refs.dataInfo.validate()) {
					this.stepTitleId = 3
				} else if(this.$refs.account.validate()){
					this.stepTitleId = 4
				}else {
					isSubimt = true
					isStep6 = true
				}
				console.log(isSubimt)
				if (isSubimt) {
					var info = this.getInfo()
					console.log("info---------->>>", info)
					if (info.object.datas.length == 0 && info.object.resources.length == 0 && info.object.tools.length == 0) {
						this.$Message.error("请至少填写一种资源申请!")
						isSubimt = false
						isStep6 = false
					}
					if (info.object.account.people.length > 0) {
						info.object.account.people.some(item => {
							console.log("item.peopleUserId--->", item.peopleName)
							if (item.peopleName != undefined && item.peopleName != null && item.peopleName != "" && (item.fourA ==
									undefined || item.fourA == null || item.fourA == '')) {
								this.$Message.error("请至少填写【" + item.peopleName + "】的4A账号!")
								isSubimt = false
								isStep6 = false
								return true
							}
						})
					}
				}

				if (this.stepTitleId != 6 && isStep6) {
					this.$refs.stepInfo.chlickStep(6)
					this.$Modal.info({
						title: "温馨提示：",
						content: "请最终确认申请相关信息！"
					});
					isSubimt = false
				}

				return isSubimt
			},

			// 获取处理时需要提交的参数
			getHandleParams(handleInfo) {
				handleInfo.reqSubject = this.applyinfo.reqSubject
				handleInfo.startTime = 0
				handleInfo.hopeTime = 0
				handleInfo.reqDes = this.applyinfo.projectInfo.projectDoc
				handleInfo.isEdit = this.isEdit;
				handleInfo.isChangeContent = 0;
				if (!this.ifedit) {
					handleInfo.isChangeContent = 1;
				}
				if (this.isEdit == 1) {
					console.log("aaaa-------->", !this.ifedit, this.isEdit)
					handleInfo.roleId = this.applyinfo.projectInfo.roleId;
					handleInfo.projectId = this.applyinfo.projectInfo.projectId;
					handleInfo.content = this.getInfo()
				}
			},
			//处理页面获取下一步处理人需要的参数
			getHandleUserParams(opOptions) {
				var param = {}
				if (opOptions != "") {
					param.vari = opOptions
				}
				param.roleId = this.applyinfo.projectInfo.roleId;
				param.projectId = this.applyinfo.projectInfo.projectId;
				return param
			},

			//格式化日期
			formatDate(value) {
				var date = new Date(value * 1000);
				var year = date.getFullYear();
				var month = this.padDate(date.getMonth() + 1);
				var day = this.padDate(date.getDate());
				var hours = this.padDate(date.getHours());
				var minutes = this.padDate(date.getMinutes());
				var seconds = this.padDate(date.getSeconds());
				return year + '-' + month + '-' + day + ' ' + hours + ':' + minutes + ':' + seconds;
			},
			padDate(value) {
				return value < 10 ? '0' + value : value;
			},

			formatTime(value) {
				return this.utils.formatDate(new Date(value * 1000), "yyyy-MM-dd")
			},
		},
		props: {
			isEdit: {},
			value: {
				default: false
			},
			ifedit: {
				type: Boolean,
				default: false,
			},
			reqId: {
				default: null
			},
			draftsId: {
				default: null
			},
			filesList: {},
			processInfo: {},
			ishidden: {
				type: Boolean,
				default: false,
			},
		},
		computed: {
			newValue: {
				get: function() {
					return this.value;
				},
				set: function(value) {
					this.$emit('input', value);
				}
			},
		},
		watch: {
			newValue(val) {
				if (val) {
					var base = this.myElement.getElement(this.baseId);
					console.log("=====get打印111=====", base);
					this.printBaseInfo = base.object;
					this.baseInfoLength = base.length;

					var project = this.myElement.getElement(this.projectInfoId);
					console.log("=====get打印111=====", project);
					this.printProject = project.object;
					this.projectInfoLength = project.length;
					this.print()
				}
			}
		},
	}
</script>
